package org.pitest.ant;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Aidan Morgan
 */
public class ExcludedMethods {
  private PitestAntTask task;
  private List<Filter> filters;

  public ExcludedMethods(PitestAntTask task) {
    this.task = task;
    this.filters = new ArrayList<Filter>();
  }

  public List<Filter> getFilters() {
    return Collections.unmodifiableList(filters);
  }

  public Filter createFilter() {
    Filter m = new Filter(task);
    filters.add(m);

    return m;
  }

  public String asString(String seperator) {
    StringBuffer buff = new StringBuffer();
    String sep = "";

    for (final String s : asList()) {
      buff.append(sep);
      buff.append(s);

      sep = seperator;
    }


    return buff.toString();
  }

  public List<String> asList() {
    List<String> result = new ArrayList<String>();

    for (final Filter tc : getFilters()) {
      result.add(tc.getFilter());
    }


    return result;
  }

  public int size() {
    return asList().size();
  }
}
